﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;
using DAO;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace GUI
{
    public partial class FormHoaDon : Form
    {
        public FormHoaDon()
        {
            InitializeComponent();
        }
        public HOADONDTO HDTO;
        private void FormHoaDon_Load(object sender, EventArgs e)
        {
            //THAMSODTO TDTO = new THAMSODTO();
            dtpThoiGian.Value = DateTime.Now;
            RHOADON rHD = new RHOADON();
            if (DataProvider.UID == null)
                rHD.SetDatabaseLogon("", "", DataProvider.NamePC, DataProvider.DataBase);
               // s = "Data Source=" + namePC + ";Integrated Security=SSPI;Initial Catalog=" + dataBase;
            else
                rHD.SetDatabaseLogon(DataProvider.UID, DataProvider.Pwd, DataProvider.NamePC, DataProvider.DataBase);
              // s = "Data Source=" + namePC + ";Integrated Security=SSPI;Initial Catalog=" + dataBase + ";uid=" + uID + ";pwd=" + pwd + ";";
            //rHD.SetDatabaseLogon("", "", "BLCSLVL\\MYSQL", "QLNH2", true);
            rHD.SetParameterValue("@MaHD", HDTO.MaHD);
            rHD.SetParameterValue("@ThoiGian", HDTO.ThoiGian);
            rpV.ReportSource = rHD;
            rpV.Refresh();
        }
        private void dtpThoiGian_ValueChanged(object sender, EventArgs e)
        {
            RHOADON rHD = new RHOADON();
            rHD.SetParameterValue("@MaHD", HDTO.MaHD);
            rHD.SetParameterValue("@ThoiGian", dtpThoiGian.Value);
            rpV.ReportSource = rHD;
            rpV.Refresh();
        }
        private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void btnDongY_Click(object sender, EventArgs e)
        {
            rpV.PrintReport();
            this.Close();
        }
    }
}
